#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>

FILE* image;

void PutImage(char* Name)
{
	printf("--myboundary\n");
	printf("Content-Type: image/jpg\n\n");
	if (!(image = fopen(Name, "rb")))
	{
		return;
	}
	char a[1000000];
	fseek(image, 0, SEEK_END);
	int Length = ftell(image);
	fseek(image, 0, SEEK_SET);
	Length = fread(&a, 1, Length, image);
	fwrite(&a, 1, Length, stdout);
	fclose(image);
}

void Wait3Second()
{
	time_t Start = time(NULL);
	while (difftime(time(NULL), Start) < 3);
}

void main(void)
{
	printf("MIME-Version: 1.0\n");
	printf("Content-Type: multipart/x-mixed-replace; boundary = myboundary\n\n");
	int res = _setmode(_fileno(stdout), _O_BINARY);
	PutImage("../images/1.jpg");
	Wait3Second();
	PutImage("../images/2.jpg");
	Wait3Second();
	PutImage("../images/3.jpg");
	printf("\n--myboundary--\n");
}
